import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
const login = () => import('../components/login.vue')
const test = () => import('../components/test.vue')
const index = () => import('../components/index/index.vue')
const echart = () => import('../components/index/chart.vue')
const menuList = () => import('../components/menu/list.vue')
const menuAdd = () => import('../components/menu/info.vue')
const roleList = () => import('../components/role/list.vue')
const roleAdd = () => import('../components/role/info.vue')
const adminList = () => import('../components/admin/list.vue')
const adminAdd = () => import('../components/admin/info.vue')
const categoryList = () => import('../components/category/list.vue')
const categoryAdd = () => import('../components/category/info.vue')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/login',
      name: 'login',
      component: login
    },
    {
      path: '/test',
      name: 'test',
      component: test
    },
    {
      path: '/index',
      name: 'index',
      component: index,
      // 子路由，嵌套的小组件对应的内容
      children: [
        // 默认的子路由，就是path为空的那个
        {path: '', component: echart, meta: {title: '图表'}},
        // 菜单列表页
        {path: 'menu', component: menuList},
        // 菜单添加页
        {path: 'menuadd', component: menuAdd},
        // 菜单修改页。页面的内容和菜单添加页几乎一样，所以使用动态路由,通过id获取这个菜单的数据
        {path: 'menu/:id', component: menuAdd},
        // 角色列表页
        {path: 'role', component: roleList},
        // 角色添加页
        {path: 'roleadd', component: roleAdd},
        // 角色修改页
        {path: 'role/:id', component: roleAdd},
        // 管理员列表页
        {path: 'admin', component: adminList},
        // 管理员添加页
        {path: 'adminadd', component: adminAdd},
        // 管理员修改页
        {path: 'admin/:uid', component: adminAdd},
        // 商品分类列表页
        {path: 'category', component: categoryList},
        // 商品分类添加页
        {path: 'categoryadd', component: categoryAdd},
        // 商品分类修改页
        {path: 'category/:id', component: categoryAdd},
      ]
    },
    
  ]
})
